<?php

class Application_Model_Filter_PayBillSearch {

      /**
       *
       * @var type 快速搜索
       */
      public $quick;

      /**
       *
       * @var type 起始时间
       */
      public $dateinbegin;

      /**
       *
       * @var type 结束时间
       */
      public $dateinend;

      /**
       *
       * @var type 状态
       */
      public $status;
      /**
       *
       * @var type 类型
       */
      public $type;
      /**
       *
       * @var type 用户Id
       */
      public $accountId;

      function getSearchFileds() {
            $where = array();
            $and = "";
            if ($this->quick != "") {
                  $and = "(";
                  $userItem = Application_Model_User::getByNikeNameStore($this->quick);
                  if ($userItem) {
                        $userid = "(";
                        foreach ($userItem as $uservalue) {
                              $userid .= $uservalue->id . ",";
                        }
                        $userid .= "0)";
                        $where[$and . " accountId in "] = $userid;
                        $and = " or ";
                  }
                  $where[$and . " txnId like "] = "%" . $this->quick . "%";
                  $and = " and ";
                  $where[$and . " 1 ) and "] = "1";
                  $and = "  and ";
            }
            if ($this->dateinbegin != "") {
                  $where[$and . " dateCreated>= "] = $this->dateinbegin;
                  $and = " and ";
            }
            if ($this->dateinend != "") {
                  $where[$and . " dateCreated<= "] = $this->dateinend;
                  $and = " and ";
            }
            if ($this->status != "") {
                  $where[$and . " status = "] = $this->status;
                  $and = " and ";
            }
            if ($this->type != "") {
                $where[$and . " type = "] = $this->type;
                  $and = " and ";
            }
            if($this->accountId != "") {
                $where[$and . " accountId = "] = $this->accountId;
                  $and = " and ";
            }
            //$where[$and . " txnId != "] = "";
//            var_dump($where);exit;
            return $where;
      }

}
